<?
$r = "../";
require_once($r."_engine/header_nocache.php");
require_once($r."_engine/c_account.php");
require_once($r."_engine/c_plan.php");
require_once($r."_config/ipn.php");



//if user logged in
if ($g_session->IsActive()) {
	$account = GetActiveAccount(false);
	$plan = new CPlan($account->data["plan_id"]);
}
$plans = CPlan::GetPlans();

$p = "plans";

include $r."_header.php";
?>

<script type="text/javascript">
<!--
var subMenuPage;
var selectedService;
var paymentMethod;
var loggedIn = false;
var isTrial = false;
var startPP;
var startWM;
var currentPlan = "<? echo $plan->id; ?>";
var selectedPlan = "<? echo $plan->id; ?>";


function setSubscrparams(){
  	var serviceID;
	var i=1;
  	while (document.getElementById('f_plan_id_'+i)){
  		if(document.getElementById('f_plan_id_'+i).checked){
			selectedPlan = document.getElementById('f_plan_id_'+i).value;

			// set PayPal params
			//startPP = document.getElementById('price_'+i).value;
			document.paypalForm.elements['a3'].value = document.getElementById('price_'+i).value;
			document.paypalForm.elements['p3'].value = document.getElementById('time_'+i).value;
			document.paypalForm.elements['t3'].value = document.getElementById('units_'+i).value;
			//document.paypalForm.elements['amount'].value = document.getElementById('price'+i).value;
			document.paypalForm.elements['item_name'].value = document.getElementById('item_name_'+i).value;
			document.paypalForm.elements['invoice'].value = document.getElementById('invoice_'+i).value;
/*
			// set Webmoney params
			startWM = document.getElementById('discount'+i).value
			document.webmoneyForm.elements['LMI_PAYMENT_AMOUNT'].value = document.getElementById('discount'+i).value;
			document.webmoneyForm.elements['LMI_PAYMENT_DESC'].value = document.getElementById('name'+i).value;
			document.webmoneyForm.elements['invoice'].value = document.getElementById('invoice'+i).value;

			// set Egold params
			startWM = document.getElementById('price'+i).value;
			document.egoldForm.elements['PAYMENT_AMOUNT'].value = document.getElementById('price'+i).value;
			document.egoldForm.elements['SUGGESTED_MEMO'].value = document.getElementById('name'+i).value;
			document.egoldForm.elements['invoice'].value = document.getElementById('invoice'+i).value;

			// set Egold params
			startCG = document.getElementById('price'+i).value;
			document.BB_BuyButtonForm.elements['item_price_1'].value = document.getElementById('price'+i).value;
			document.BB_BuyButtonForm.elements['item_name_1'].value = document.getElementById('name'+i).value;
			document.BB_BuyButtonForm.elements['item_description_1'].value = document.getElementById('name'+i).value+" | "+document.getElementById('invoice'+i).value;
			document.BB_BuyButtonForm.elements['shopping-cart_items_item-1_unit-invoice'].value = document.getElementById('invoice'+i).value;
*/
			selectedService = i; //set selected service var for not logged in users
        }
		i++;
  	}
  	//alert(document.paypalForm.elements['a3'].value+" "+document.paypalForm.elements['p3'].value+" "+document.paypalForm.elements['invoice'].value+" - "+selectedPlan)
	//alert(document.paypalForm.elements['a3'].value+" "+document.paypalForm.elements['p3'].value+" "+document.paypalForm.elements['invoice'].value);
}


function submitPaymentForm() {
	if (document.paypalForm.elements['a3'].value == 'FREE') {
		alert("Please choose payed subscription plan.");
		return false;
	}
	if (currentPlan == selectedPlan) {
		alert("You are currently subscribed to this plan!\nPlease choose another one.");
		return false;
	}

	document.getElementById(paymentMethod).submit();
}

function setPaymentMethod(){
            //paymentMethod = document.getElementsByName('method')[i].value;
			paymentMethod = 'paypalForm';

}
//-->
</script>

<!--
<table border="1" cellspacing="0" cellpadding="2" class="tbl" width="90%">
<tr>
	<td class="tblHTD" style="padding-left: 30;"><span class="text">Plan</td>
	<td class="tblHTD"><span class="text">Number of monitors</td>
	<td class="tblHTD"><span class="text">History Size</td>
	<td class="tblHTD"><span class="text">Cost</td>
	<td class="tblHTD"><span class="text">Period</td>
</tr>
<?php
$template_tbl_row = '
<tr [%STYLE%]>
			<td [%STYLE%]>';
if ($g_session->IsActive()) {
	$template_tbl_row .= '<input onClick="javascript:setSubscrparams();" type="radio" name="f_plan_id" id="f_plan_id_[%ITEM%]" value="[%PLAN_ID%]" [%CHECKED%] >';
}

$template_tbl_row .= '&nbsp;[%TITLE%]</td>

	<td class="tblTD"><span class="text"><center>[%MAX_MONITORS%]</center></td>
	<td class="tblTD"><span class="text"><center>[%HISTORY_SIZE%]</center></td>
	<td class="tblTD"><span class="text">[%COST%]</td>
	<td class="tblTD"><span class="text">[%PERIOD_TEXT%]
		<input type="hidden" name="item_name_[%ITEM%]" id="item_name_[%ITEM%]" value="[%TITLE%]">
		<input type="hidden" name="item_number_[%ITEM%]" id="item_number_[%ITEM%]" value="[%PLAN_ID%]">
		<input type="hidden" name="price_[%ITEM%]" id="price_[%ITEM%]" value="[%COST%]">
		<input type="hidden" name="time_[%ITEM%]" id="time_[%ITEM%]" value="[%PERIOD_L%]">
		<input type="hidden" name="units_[%ITEM%]" id="units_[%ITEM%]" value="[%PERIOD_T%]">
		<input type="hidden" name="invoice_[%ITEM%]" id="invoice_[%ITEM%]" value="[%USER%]_[%PLAN_ID%]_[%TIME%]_[%PERIOD_L%]_[%PERIOD_T%]">
	</td>
</tr>
';
$counter = 1;
foreach ($plans as $pl)
{

	$a = array(
		'TITLE'      	=> $pl->data["title"],
		'MAX_MONITORS'	=> $pl->data["max_monitors"],
		'HISTORY_SIZE'  => $pl->data["history_size"],
		'COST'     		=> ($pl->data["cost"] > 0.00 ? "$".$pl->data["cost"] : "FREE"),
		'PERIOD_TEXT'	=> $pl->GetPeriodText(),
		'USER' 			=> "",
		'CHECKED' 		=> "",
		'STYLE' 		=> ""
	);

	//if user logged in
	if ($g_session->IsActive()) {
		$a['USER'] = $account->id;
		if ($pl->id == $plan->id)
		{
			$a['CHECKED'] = "checked";
			$a['STYLE'] = "class='planSelected'";
			//foreach ($a as $k => $v){$a[$k] = "<b>" . $a[$k] . "</b>";}
		}
	}

	$a['TIME'] = time();
	$a['ITEM'] = $counter;
	$a['PLAN_ID'] = $pl->id;
	$a['PERIOD_L'] = $pl->GetPeriodL();
	$a['PERIOD_T'] = $pl->GetPeriodT();



    //echo process_template($template_tbl_row, $a);
	$counter++;
}
?>
</table>
-->

<br>
<center>
<? //if user logged in
if ($g_session->IsActive()) { ?>

<? } else { ?>
<p >Please Sign Up for the <a href="<?=HrefToPage("signup")?>">Free Trial</a> or <a href="<?=HrefToPage("login")?>">Sign In</a> first to choose a subscription plan.</p>

<?php
} ?>
</center>
<?

//if user logged in
if ($g_session->IsActive()) {
	$form_paypal = '
	<form action="https://www.paypal.com/cgi-bin/webscr" name="paypalForm" id="paypalForm" method="post">
	<input type="hidden" name="cmd" value="_xclick-subscriptions">
	<input type="hidden" name="business" value="'.$ipn_paypal_business.'">
	<input type="hidden" name="item_name" value="[%TITLE%]">
	<input type="hidden" name="item_number" value="[%ID%]">
	<input type="hidden" name="no_shipping" value="1">
	<input type="hidden" name="return" value="'.$ipn_paypal_return.'" />
	<input type="hidden" name="rm" value="2" />
	<input type="hidden" name="cancel_return" value="'.$ipn_paypal_cancel_return.'" />
	<input type="hidden" name="notify_url" value="'.$ipn_paypal_notify_url.'">
	<input type="hidden" name="a3" value="[%COST%]">
	<input type="hidden" name="p3" value="[%PERIOD_L%]">
	<input type="hidden" name="t3" value="[%PERIOD_T%]">
	<input type="hidden" name="no_note" value="1" />
	<input type="hidden" name="invoice" value="" />
	<input type="hidden" name="currency_code" value="USD" />
	<input type="hidden" name="modify" value="0">
	<input type="hidden" name="usr_manage" value="0" />

	</form>';

	$a = array(
		'ID'	      	=> $plan->id,
		'TITLE'      	=> $plan->data["title"],
		'COST'     		=> $plan->data["cost"],
		'PERIOD_L'		=> $plan->GetPeriodL(),
		'PERIOD_T'		=> $plan->GetPeriodT(),
	);

	echo process_template($form_paypal, $a);
}

?>


<script type="text/javascript">
<!--
setSubscrparams();
setPaymentMethod('paypal');

//-->
</script>







				
				
<TABLE class="featuresTbl" border='0' cellSpacing='0'  cellPadding="0" width="100%">
  <TBODY>
  <TR>

    <TD style="vertical-align:top;  WIDTH: 100%;" align="center"  colspan="2">
        <table border="0"  cellPadding=3 style=" vertical-align:top; WIDTH: 100%;">
            <tbody>
                <tr><td align="center" ><SPAN class="basic">Professional</SPAN></td></tr>
                <!--tr><td class="pricing_row" class="pricing_row" style="height:170px;"><img src="/images/pricing/Pro.gif" border="0" /></td></tr-->
                <tr><td  align="center" ><SPAN class="basic">$99.95 / Year</SPAN></td></tr>

              <tr><td   align="center" style="height:120px" >
                  <SPAN>For small-to-medium businesses whose business is strongly rely on their products&rsquo; <br/> 
                                    branding and want to increase  customer&rsquo;s satisfaction in the most sufficient way
                   </SPAN>
                   
                   </td></tr>
                   <!-- tr>  <td  align="center" class="pricing_row" style="vertical-align:top;"  class="pricing_row"></td>
                 </tr -->
                  </tbody>
        </table>
        </TD>
    
    </TR>

<TR>

    <TD style="vertical-align:top;  WIDTH: 60%;" align="center"  colspan="2">
        <table border="0"  cellPadding=3 style=" vertical-align:top; WIDTH: 60%;">
            <tbody>	
	
<TR>
    <TD bgcolor="#FFFFFF" class="features" vAlign=top> Quantity of monitors (pages or RSS feeds):</TD>
    <TD bgcolor="#FFFFFF" vAlign=top class="features" align="center"> <b>100</b></TD></TR>
<TR>
    <TD bgcolor="#FFFFFF" class="features"  vAlign=top>Max. tracking frequency:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center"  ><b>Hourly</b></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" class="features" vAlign=top>E-mail alerts and web dashboard:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" class="features" vAlign=top>Multilingual support:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Changes highlighting:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
   <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Changes navigator:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
   <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Search engine tracking:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
   <tr>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Advanced Filtering & Noise Reduction:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
      
   <tr>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Custom time of notification:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
   <tr>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>RSS/Atom tracking &amp; output:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
      
   <tr>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Browser plug-in*:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
      
  <tr>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>SMS notification:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
        
  <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Multiple emails/groups:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Stealth mode monitoring:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Hidden web monitoring (track password protected pages):</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>
  <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Account&#39;s customization:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><IMG  
      src="/images/pricing/bul_enabled.gif" 
      width=15 height=15></TD></TR>

  <TR>
    <TD bgcolor="#FFFFFF" class=features vAlign=top>Free Trial:</TD>
    <TD vAlign=top bgcolor="#FFFFFF" class="features" align="center" ><b>30-days</b></TD>
</TR>

    </tbody>
        </table>
        </TD>
    
    </TR>
	 <TR>

    <TD style="vertical-align:top;  WIDTH: 100%;" align="center"  colspan="2">
        <table border="0"  cellPadding=3 style=" vertical-align:top; WIDTH: 100%;">
            <tbody>
                   <tr>
                   <td  align="center" style="vertical-align:top;">
				   <? //if user logged in
					if ($g_session->IsActive()) { ?>
                   <img src="/images/pricing//btn_signupchart_large.png" vspace="5" class="image_button" 
					onclick="<? if ($g_session->IsActive()) echo "document.getElementById('paymentForm_3').submit()"; ?>" />
					<? } ?>
					<br />
					<nobr><img src="/images/pay/logo_ccVisa.gif" />
					<img src="/images/pay/logo_ccMC.gif" />
					<img src="/images/pay/logo_ccAmex.gif" />
					<img src="/images/pay/logo_ccDiscover.gif" />
					<img src="/images/pay/PayPal_mark_37x23.gif" /></nobr>
                   </td></tr>
            </tbody>
        </table>
        </TD>
    </TR>
    	</TBODY></TABLE>
	
	<div>
	
		<p><b>Hosted Edition</b><br />
Interested to host W3Monitor in your own data-center? <a href="/company/contact.php">Contact</a> us for the details.</p>

<p><b>Browser plug-in</b><br />
Coming soon.</p>
	
	</div>
				
		

<?
foreach ($plans as $pl)
{
$current_plan = $pl->id;

$form_payment = '

	<form action="plans_process.php" name="paymentForm_'.$current_plan.'" id="paymentForm_'.$current_plan.'" method="post">
	<input type="hidden" name="account" value="[%ACCOUNT%]">
	<input type="hidden" name="plan" value="[%PLAN%]">
	<input type="hidden" name="title" value="[%TITLE%]">
	<input type="hidden" name="description" value="[%DESCRIPTION%]">
	<input type="hidden" name="cost" value="[%COST%]">
	<input type="hidden" name="currency" value="[%CURRENCY%]">
	<input type="hidden" name="period" value="[%PERIOD%]">
	<input type="hidden" name="units" value="[%UNITS%]">
	</form>';

	$a = array(
		'ACCOUNT'	    => $account->id,
		'PLAN'	      	=> $current_plan,
		'TITLE'      	=> $pl->data["title"],
		'DESCRIPTION'	=> "W3Monitor subscription plan",
		'COST'     		=> $pl->data["cost"],
		'CURRENCY'		=> $pl->data["currency"],
		'PERIOD'		=> $pl->data["period"],
		'UNITS'			=> $pl->data["period_units"]
	);
	echo process_template($form_payment, $a);

}


include $r."_footer.php";
?>
